package cn.rongdao.jrkabao.ui.main.mainfragment.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.mifengkong.frtools.inputmethod.FRView;
import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerAdapter;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.main.vip.MemberBean;
import cn.rongdao.jrkabao.bean.main.vip.VipBean;

/**
 * Created by jack on 2018/1/26
 */
public class VipAdapter extends FRBaseRecyclerAdapter<MemberBean.VipConfigBean, VipViewHolder> {

    public VipAdapter(Context context, OnItemClickListener<VipViewHolder> listener) {
        super(context, listener);
    }

    @Override
    public VipViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new VipViewHolder(FRView.inflateLayout(getContext(), R.layout.item_vip, parent, false));
    }

    public void setItemSelect(int position) {
        for (int i = 0; i < getDataList().size(); i++) {
            if (i == position) {
                getDataList().get(i).setSelect(true);
                continue;
            }
            getDataList().get(i).setSelect(false);
        }
        notifyDataSetChanged();
    }

    public boolean isSelect(int position) {
        return getDataList().get(position).isSelect();
    }

    public void initSelect() {
        getDataList().get(0).setSelect(true);
    }
}
